<?php
class site_k_entry extends ss_konstrukt_detailComponent {
	protected $templates;
	protected $structureMapper;
	protected $entryMapper;
	protected $strucure;
	protected $entry;
	protected $content;
	
	public function __construct(ss_core_settings $ss_settings, 
			site_templatefactory $templates, 
			site_dao_structure_mapper $structureMapper, 
			site_dao_entry_mapper $entryMapper,
			ss_core_injectorInterface $injector){
		$this->structureMapper=$structureMapper;
		$this->entryMapper=$entryMapper;
		$this->structure=$structureMapper->api_master();
    	$this->templates = $templates;
		$this->settings=$ss_settings;
		$this->injector=$injector;
	}
	
	public function dispatch(){
		ss_error::log('Entry dispatch');
		if(!is_object($this->entry=$this->context->entry())){
			$this->entry=$this->entryMapper->getEntryBySlug($this->name());
		}
		return parent::dispatch();
	}
	
	public function GET(){
		ss_error::log('Entry GET');
		$this->content=$this->entry->detail();
		return parent::GET();
	}
	
	protected function renderHtml() {
		ss_error::log('Entry HTML');
    	$smarty = $this->templates->create();
	    $smarty->assign_by_ref('content',$this->content);
		$smarty->register_object('ss_path', $this->settings->server->appath);
	    $smarty->assign_by_ref('context', $this);
    	return $smarty->fetch("entry.tpl");
	}
}
?>